/**
 * 
 */
package uk.ac.manchester.tewpl.iceiface.client.model;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import com.extjs.gxt.ui.client.data.BaseModelData;
import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * @author roland
 * 
 */
public class KBCommunityModel extends BaseModelData implements IsSerializable {
	private KBWorkspaceModel dummyWorkspace;
	private KBUserModel dummyUser;
	/**
	 * 
	 */
	private static final long serialVersionUID = -321379680722984426L;
	public static final String ID = "id";
	public static final String NAME = "name";
	public static final String DESCRIPTION = "description";
	public static final String MEMBERS = "members";
	public static final String WORKSPACES = "workspaces";

	/**
	 * 
	 */
	public KBCommunityModel() {
		set(MEMBERS, new HashSet<KBUserModel>());
		set(WORKSPACES, new HashSet<KBWorkspaceModel>());
	}

	/**
	 * @param properties
	 */
	public KBCommunityModel(Map<String, Object> properties) {
		super(properties);
		// TODO Auto-generated constructor stub
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.explorium.model.KBCommunity#addKnowledgeBase(org.explorium.model.
	 * .KBInfo)
	 */
	/*public void addKnowledgeBase(KBInfoModel kbInfo) {
		getWorkspaces().add(kbInfo);
	}*/

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.explorium.model.KBCommunity#addMember(org.explorium.model..KBUser)
	 */
	public void addMember(KBUserModel user) {
		getMembers().add(user);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.explorium.model.KBCommunity#getDescription()
	 */
	public String getDescription() {
		return get(DESCRIPTION);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.explorium.model.KBCommunity#getId()
	 */
	public Long getId() {
		// TODO Auto-generated method stub
		return get(ID);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.explorium.model.KBCommunity#getKnowledgeBases()
	 */
	public Set<KBInfoModel> getWorkspaces() {
		// TODO Auto-generated method stub
		return get(WORKSPACES);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.explorium.model.KBCommunity#getMembers()
	 */
	public Set<KBUserModel> getMembers() {
		// TODO Auto-generated method stub
		return get(MEMBERS);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.explorium.model.KBCommunity#getName()
	 */
	public String getName() {
		// TODO Auto-generated method stub
		return get(NAME);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.explorium.model.KBCommunity#removeKnowledgeBase(org.explorium.model
	 * .KBInfo)
	 */
	/*public void removeKnowledgeBase(KBInfoModel kbInfo) {
		getWorkspaces().remove(kbInfo);
	}*/

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.explorium.model.KBCommunity#removeMember(org.explorium.model.KBUser)
	 */
	public void removeMember(KBUserModel user) {
		getMembers().remove(user);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.explorium.model.KBCommunity#setDescription(java.lang.String)
	 */
	public void setDescription(String description) {
		set(DESCRIPTION, description);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.explorium.model.KBCommunity#setId(java.lang.Long)
	 */
	public void setId(Long id) {
		set(ID, id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.explorium.model.KBCommunity#setKnowledgeBases(java.util.Set)
	 */
	public void setWorkspaces(Set<KBWorkspaceModel> workspaces) {
		set(WORKSPACES, workspaces);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.explorium.model.KBCommunity#setMembers(java.util.Set)
	 */
	public void setMembers(Set<KBUserModel> members) {
		set(MEMBERS, members);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.explorium.model.KBCommunity#setName(java.lang.String)
	 */
	public void setName(String name) {
		set(NAME, name);
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof KBCommunityModel) {
			KBCommunityModel o = (KBCommunityModel) obj;
			return getId().equals(o.getId());
		}
		return false;
	}

}
